import cn.hutool.crypto.digest.MD5;

import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class client {
    private final static String secretKey = "LZVZJ31K2C2xxPhehUU6hu6e8Y4LkF0s"; //不能参与传输
    private final String appId = "CZI2DyKnKt4z8n2KPV5OmClA";

    public String getAppId() {
        return appId;
    }

    /**
     * 第三方工具
     *
     * @param content 要加密的内容
     * @return signature 签名
     */
    public String getSignature(String content) {
        return cn.hutool.crypto.digest.MD5.create().digestHex(content, StandardCharsets.UTF_8);
    }

    /**
     * jdk提供的标准MD5
     * @param content 要加密的内容
     * @return signature 签名
     */
    public String getSignature2(String content) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] inputData = content.getBytes(StandardCharsets.UTF_8);
            byte[] digest = md.digest(inputData);
            StringBuffer sb = new StringBuffer();
            for (byte b : digest) {
                // 将字节转换成16进制字符
                sb.append(String.format("%02x", b & 0xff));
            }
            return sb.toString();
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException("编码失败");
        }
    }
}